#include <bits/stdc++.h>//40
using namespace std;
#define lowbit(x) x&(-x)
const int N=1e5+5;
int t;
int n,m,l,v,dis[N];
struct car
{
    int d,v,a;
    int ca;
    int r;

}c[N];
struct p
{
    int x,y;
    bool operator < (const p &a) const
    {
        return y>a.y;
    }
}w[N];
int num=0;
bool cmp(p x, p y)
{
    if (x.x==y.x)
    {
        return x.y>y.y;
    }
    return x.x<y.x;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    //freopen("detect2.out")
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>t;
    while(t--)
    {
        num=0;
        cin>>n>>m>>l>>v;
        for (int i=1;i<=n;i++)
        {
            cin>>c[i].d>>c[i].v>>c[i].a;
            if (c[i].v<=v&&c[i].a<=0) c[i].ca=-1;
            else if (c[i].v<=v&&c[i].a>0)
            {
                c[i].d=c[i].d+(int)ceil((1ll*v*v-1ll*c[i].v*c[i].v)*1.0/(2*c[i].a));
                if ((1ll*v*v-1ll*c[i].v*c[i].v)%(2*c[i].a)==0) c[i].d++;
                c[i].r=l;
            }
            else if (c[i].a>=0 &&c[i].v>v) c[i].ca=1;
            else
            {
                c[i].r=c[i].d+(int)floor((c[i].v*c[i].v-v*v)*1.0/(-2*c[i].a));
                if ((c[i].v*c[i].v-v*v)%((-2*c[i].a))==0) c[i].r--;
            }
            //cout<<c[i].r<<endl;
        }
        for (int i=1;i<=m;i++)
        {
            cin>>dis[i];
        }
        dis[m+1]=10000000;
        for (int i=1;i<=n;i++)
        {
            //cout<<num<<" ";
            if (c[i].ca==1)
            {
                int t=lower_bound(dis+1,dis+m+1,c[i].d)-dis;
                if (t>m) c[i].ca=-1;
                else
                {
                    c[i].r=l;
                    num++;
                }

                continue;
            }
            else if (c[i].ca==-1) continue;
            else if (c[i].a>0)
            {
                int t=lower_bound(dis+1,dis+m+1,c[i].d)-dis;
                if (t<=m) num++;
                else c[i].ca==-1;
            }
            else
            {
                int t=lower_bound(dis+1,dis+m+1,c[i].d)-dis;
                //if (i==5) cout<<dis[t];
                if (t<=m && dis[t]<=c[i].r) num++;
                else c[i].ca=-1;
            }
            //cout<<i<<" "<<num<<'\n';

        }
        /*for (int i=1;i<=n;i++)
        {
            cout<<c[i].ca<<'\n';
        }*/
        cout<<num<<" ";
        int cnt=0;
        for (int i=1;i<=n;i++)
        {
            if (c[i].ca!=-1)
            {
                w[++cnt]=(p){c[i].d,c[i].r};
            }
        }
        sort(w+1,w+cnt+1,cmp);
        /*for (int i=1;i<=cnt;i++)
        {
            cout<<w[i].x<<" "<<w[i].y<<'\n';
        }*/
        num=0;
        priority_queue <p> q;
        int now=1;
        for (int i=1;i<=m;i++)
        {
            while(now<=cnt&&w[now].x<=dis[i])
            {

                q.push({w[now].x,w[now].y});
                now++;
            }
            if (q.empty()) continue;
            p o=q.top();
            if (o.y<dis[i+1])
            {
                num++;
                //cout<<dis[i]<<" ";
                while(!q.empty()) q.pop();
                //<<dis[i]<<" ";
            }

        }
        cout<<m-num<<'\n';
        memset(dis,0,sizeof(dis));
        for (int i=1;i<=n;i++)
        {
            c[i].ca=0;
        }


    }
    return 0;
}
